package cn.klaw.job.admin.config;

import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import cn.klaw.job.admin.service.HandlerNameService;
import cn.klaw.util.context.SpringContext;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

/**
 *
 *
 * @version V3.1.0
 *
 * @date 2021/3/16 8:49
 */
@Component
public class XxlJobListener implements ApplicationRunner {
    @Override
    public void run(ApplicationArguments args) throws Exception {
        HandlerNameService handlerNameService = SpringContext.getBean(HandlerNameService.class);
        handlerNameService.removeAll();
    }

    @Bean
    public MybatisPlusInterceptor pageHelper() {
        MybatisPlusInterceptor mybatisPlusInterceptor = new MybatisPlusInterceptor();
        mybatisPlusInterceptor.addInnerInterceptor(new PaginationInnerInterceptor());
        return mybatisPlusInterceptor;
    }
}
